package com.woniuxy.lab.woniu_lab.controller;


import com.woniuxy.lab.woniu_lab.commons.Result;
import com.woniuxy.lab.woniu_lab.service.RangeUserService;
import com.woniuxy.lab.woniu_lab.service.dto.RangeDto;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * <p>
 * 靶场-用户关联表 前端控制器
 * </p>
 *
 * @author Silas
 * @since 2023-03-15
 */
@RestController
@RequestMapping("/rangeUser")
@Api(tags="[J]靶场-用户相关接口")
@Slf4j
@Validated
public class RangeUserController {

    @Resource
    private RangeUserService rangeUserService;

    /**
     * 判断用户是否可查看靶场
     * @param rangeId 靶场ID
     * @return RangeDto
     */
    @ApiOperation("57 判断用户是否可查看实验")
    @GetMapping("/checkPay")
    public Result<Boolean> checkPay(@ApiParam(value = "靶场ID") @NotNull(message = "靶场ID不能为空") @Min(value = 1,message = "靶场ID最小为1") Integer rangeId){
        log.info("开始查询用户是否购买靶场：{}",rangeId);
            Boolean b= rangeUserService.checkPay(rangeId);
            return Result.success(200,"查询用户是否购买靶场成功",b);
    }

}

